home *** CD-ROM | disk | FTP | other *** search
-
- /* copy the two fats into the new partition */
-
- fcpfats(dev, n, stsrc, stdes, buf, siz)
-
- int dev;
- int n;
- long stsrc;
- long stdes;
- char *buf;
- long siz;
-
-
- {
-
- int ret, fat2=1;
- long endsrc, tmpstsrc, tmpstdes ;
-
- tmpstdes = stdes + 1; /* 1 sector is for the boot sect */
- tmpstsrc = stsrc + 1;
- endsrc = tmpstsrc + prvhdr[n].fatsiz; /* 1 sector is for the boot sect */
- cpfat:
- while (tmpstsrc != endsrc) {
- if ((tmpstsrc + siz) > endsrc)
- siz = endsrc - tmpstsrc;
-
- if ((ret = rdsects(dev,(UWORD)siz, buf, tmpstsrc)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
-
- if ((ret = wrsects(dev,(UWORD)siz, buf, tmpstdes)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
- tmpstsrc += siz;
- tmpstdes += siz;
- }
- zerosect(dev, tmpstdes, newhdr[n].fatsize - prvhdr[n].fatsiz);
- if (fat2) {
- fat2 = 0;
- tmpstsrc = 1 + stsrc + prvhdr[n].fatsiz;
- tmpstdes = 1 + stdes + newhdr[n].fatsize;
- endsrc = tmpstsrc + prvhdr[n].fatsiz;
- goto cpfat;
- }
- return(OK);
- }
-
-
-
- /* copy the directory into the new partition */
-
- fcpdir(dev, n, stsrc, stdes, buf, siz)
-
- int dev;
- int n;
- long stsrc;
- long stdes;
- char *buf;
- long siz;
-
-
- {
-
- int ret;
- long endsrc;
-
- stsrc = 1 + stsrc + 2 * prvhdr[n].fatsiz;/* 1 sector is for the boot sect */
- endsrc = stsrc + prvhdr[n].dirsiz; /* 1 sector is for the boot sect */
- stdes = 1 + stdes + 2 * newhdr[n].fatsize;
-
- while (stsrc != endsrc) {
- if ((stsrc + siz) > endsrc)
- siz = endsrc - stsrc;
-
- if ((ret = rdsects(dev,(UWORD)siz, buf, stsrc)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
-
- if ((ret = wrsects(dev,(UWORD)siz, buf, stdes)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
- stsrc += siz;
- stdes += siz;
- }
- if ((ret = (newhdr[n].dirsize - prvhdr[n].dirsiz))) {
- /* directory size is not same */
- zerosect(dev, stdes, ret);
- }
- return(OK);
- }
-
-
-
- /* do the copy for the header from the previous partition to the new one */
-
- fcpsects(dev, stsrc, stdes, endsrc, buf, siz)
-
- int dev;
- long stsrc;
- long stdes;
- long endsrc;
- char *buf;
- long siz;
-
-
- {
-
- int ret;
-
- while (stsrc != endsrc) {
- if ((stsrc + siz) > endsrc)
- siz = endsrc - stsrc;
-
- if ((ret = rdsects(dev,(UWORD)siz, buf, stsrc)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
-
- if ((ret = wrsects(dev,(UWORD)siz, buf, stdes)) != 0) {
- if (tsterr(ret) == OK) {
- return(ERROR);
- }
- }
- stsrc += siz;
- stdes += siz;
- }
- return(OK);
- }
-
-